﻿//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2020 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------

using System.Collections.Generic;
using UnityGameFramework.Runtime;
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;

namespace StarForce
{
    public class ProcedureMain : ProcedureBase
    {
        public override bool UseNativeDialog
        {
            get
            {
                return false;
            }
        }
        /// <summary>
        /// 保存所有的游戏模式
        /// </summary>
        private readonly Dictionary<GameMode,GameBase> GameModeDic = new Dictionary<GameMode,GameBase>();
        
        /// <summary>
        /// 目前正在进行的游戏模式
        /// </summary>
        private GameBase m_currentGameMode = null;

        protected override void OnInit(ProcedureOwner procedureOwner)
        {
            base.OnInit(procedureOwner);
            GameModeDic.Add(GameMode.Adventure,new AdventureGame());
        }

        protected override void OnDestroy(ProcedureOwner procedureOwner)
        {
            base.OnDestroy(procedureOwner);
        }

        protected override void OnEnter(ProcedureOwner procedureOwner)
        {
            base.OnEnter(procedureOwner);
            //可以从主菜单中选择
            GameMode mode = GameMode.Adventure;    
            m_currentGameMode = GameModeDic[mode];
            //执行游戏模式初始化操作
            m_currentGameMode.Initialize();
        }

        protected override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown)
        {
            base.OnLeave(procedureOwner, isShutdown);
        }

        protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
        {
            base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
            m_currentGameMode.Update(elapseSeconds,realElapseSeconds);
        }
    }
}
